#ifndef GRAPHICS_VIEW_GRID_H
#define GRAPHICS_VIEW_GRID_H

#include "graphicsSceneGrid.h"
#include "shipInventory.h"
#include <QGraphicsView>
#include <QGraphicsPolygonItem>

class GraphicsViewGrid : public QGraphicsView
{
  Q_OBJECT

public:
  GraphicsViewGrid(QWidget* parent = 0);

  void clear();
  void loadShip(const ShipInventory& inventory);
  ShipInventory shipInventory() const;
  void addComponent(unsigned int row, unsigned int col,
                    const QString& componentName, const QPixmap& pixmap);

protected:
  void dragEnterEvent(QDragEnterEvent *event);
  void dragMoveEvent(QDragMoveEvent *event);
  void dragLeaveEvent(QDragLeaveEvent *event);
  void dropEvent(QDropEvent *event);

private:
  typedef QMap<unsigned int, QMap<unsigned int, QGraphicsPixmapItem*> > PositionPixmapMap; //[row][col]

  GraphicsSceneGrid mScene;
  QGraphicsPolygonItem* mHighlightRect;
  PositionPixmapMap mPositionPixmaps;
  ShipInventory mShipInventory;
};

#endif
